package com.tradeplus.admin.dao;

import com.tradeplus.admin.model.Preference;
import java.util.List;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class PreferenceDaoImpl implements PreferenceDao {
    
    private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

    @Override
    public void savePreference(Preference preference) {
        hibernateTemplate.merge(preference);
    }

    @Override
    public List<Preference> loadPreference() {
        return hibernateTemplate.find("from Preference");
    }

    @Override
    public void deletePreference(Long preferenceId) {
        hibernateTemplate.delete(hibernateTemplate.get(Preference.class, preferenceId));
    }

    @Override
    public Preference loadPreferenceById(Long preferenceId) {
        return (Preference) hibernateTemplate.get(Preference.class, preferenceId);
    }

}
